<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
session_start(); //we need to call PHP's session object to access it through CI
class Home extends MY_Controller {

 function __construct()
 {
    parent::__construct();
    $this->load->model("productmodel", "ProductModel");
 }

 function index()
 {
     $session_data = $this->session->userdata('logged_in');
     $data['username'] = $session_data['username'];
     
     
     //get list product to sell
     $this->load->model("productmodel", "ProductModel");
     $data['mComs'] = $this->ProductModel->getMComList();

     $this->renderView('home_view', $data);
 }

 function logout()
 {
   $this->session->unset_userdata('logged_in');
   session_destroy();
   redirect('home', 'refresh');
 }

    public function sellProduct(){
        
    }
    
    public function getProductDetailList(){
        if ($this->input->post()) {
            $productId = $this->input->post('product_id', true);
            //get list product to sell
            $aData['product_id'] = $productId;
            $this->load->model("productmodel", "ProductModel");

            $data['productDetails'] = $this->ProductModel->getProductDetailByFilter($aData);
            $result = $this->getHtmlFromtemplate("common/model_detail_list", $data);
            echo $result;
            return;
        }
        show_404();
    }
}

?>